#include <stdio.h>
#include "user_nvs_flash.h"
#include "esp_log.h"
#include "nvs_flash.h"

void user_wifi_nvs(void)
{
    nvs_flash_init();

}


void user_nvs(void)
{
    const char *log = "Debug";

    nvs_handle_t user_nvs_handle;

    char *flash_file_namespace = "Flash_File";
    uint32_t count = 0;
    char *count_key = "count";

    nvs_flash_init();

    nvs_open(flash_file_namespace, NVS_READWRITE, &user_nvs_handle);

    nvs_get_u32(user_nvs_handle, count_key, &count);

    count++;

    nvs_set_u32(user_nvs_handle, count_key, count);

    nvs_close(user_nvs_handle);

    nvs_flash_deinit();

    ESP_LOGI(log, "flash_file_namespace = %s \n", flash_file_namespace);
    ESP_LOGI(log, "count_key = %s \n", count_key);
    ESP_LOGI(log, "设备启动次数 = %ld \n", count);
}